const mongoose = require('mongoose')
const initComment = require('@root/InitDatas/comment.json')
const chalk = require('chalk')

const commentSchema = new mongoose.Schema({
  comments: [
    {
      avatar: Object,
      food_ratings: [
        {
          food_id: Number,
          rate_name: String,
          rating: String,
          rating_text: String,
          reply: {
            content: Object,
            created_at: Object,
          },
          sku_id: Number,
          sku_id_str: String,
          tags: Object,
        },
      ],
      highlights: Object,
      highlights_v2: {},
      interactSwitch: Number,
      interactionInfo: {
        hasPraised: Boolean,
        praiseCount: Number
      },
      isRepurchase: Boolean,
      is_myself: Object,
      is_myself_top: Object,
      is_super_vip: Boolean,
      is_taobao_vip: Boolean,
      orderVideos: [],
      order_id: Number,
      order_images: [
        {
          associatedItems: [
            {
              foodId: Number,
              index: Object,
              name: String,
              position: Object,
              skuId: Number
            },
          ],
          food_ids: [Number],
          food_indexes: Object,
          food_names: [String],
          image_hash: String,
          sku_ids: [Number],
        }
      ],
      package_rating: Number,
      quality_rating: Number,
      rateId: Number,
      rated_at: String,
      rating: Number,
      rating_text: String,
      reply: {
        content: String,
        created_at: String,
      },
      rider_rating: Number,
      selected_high_quality_rate_icon: Object,
      tags: Object,
      time_spent_desc: String,
      username: String,
    },
  ],
  rating: {
    compare_rating: String,
    deliver_time: String,
    fixedCompareRating: String,
    fixedFoodScore: String,
    fixedPackageScore: String,
    fixedRiderGoodRate: String,
    fixedRiderScore: String,
    fixedShopScore: String,
    fixedTasteScore: String,
    food_score: String,
    item_good_score: String,
    order_rating_amount: String,
    overall_score: Number,
    package_score: String,
    rider_good_rate: Number,
    rider_score: String,
    service_score: String,
    shop_score: Number,
    taste_score: String,
  },
  tags: [
    {
      count: Number,
      name: String,
      tagIdentity: {
        id: String,
        _type: Number,
      },
      unsatisfied: Boolean,
    }
  ],
  restaurant_id: String
})

const commentModel = mongoose.model('comments', commentSchema)

// 查询数据
// console.log(commentModel.find((err, data) => {
//   if(err) throw err
//   console.log(data)
// }))


// 初始化城市数据
// commentModel.insertMany(initComment, err => {
//   if (err) return chalk.red(err)
//   console.log(chalk.green("init cityList successfully..."))
// })

module.exports = commentModel
